ostree-prepare-root: make mkdir calls idempotent
authorJoseph Marrero Corchado <jmarrero@redhat.com>
Thu, 29 May 2025 18:23:00 +0000 (14:23 -0400)
committerJoseph Marrero Corchado <jmarrero@redhat.com>
Thu, 29 May 2025 18:25:43 +0000 (14:25 -0400)
src/switchroot/ostree-prepare-root.c

index 4bf180c363b5670e32ff703f3246b4906645b53c..68707f1064f42d7f0891cb473666293c13b6575f 100644 (file)
@@ -348,7 +348,7 @@ main (int argc, char *argv[])
   if (mount (NULL, "/", NULL, MS_REC | MS_PRIVATE | MS_SILENT, NULL) < 0)
     err (EXIT_FAILURE, "failed to make \"/\" private mount");
 
-  if (mkdir (TMP_SYSROOT, 0755) < 0)
+  if (mkdir (TMP_SYSROOT, 0755) < 0 && errno != EEXIST)
     err (EXIT_FAILURE, "couldn't create temporary sysroot %s", TMP_SYSROOT);
 
   /* Run in the deploy_path dir so we can use relative paths below */
@@ -384,7 +384,7 @@ main (int argc, char *argv[])
 
       cfs_options.flags = 0;
       cfs_options.image_mountdir = OSTREE_COMPOSEFS_LOWERMNT;
-      if (mkdirat (AT_FDCWD, OSTREE_COMPOSEFS_LOWERMNT, 0700) < 0)
+      if (mkdirat (AT_FDCWD, OSTREE_COMPOSEFS_LOWERMNT, 0700) < 0 && errno != EEXIST)
         err (EXIT_FAILURE, "Failed to create %s", OSTREE_COMPOSEFS_LOWERMNT);
 
       g_autofree char *expected_digest = NULL;